#include <iostream>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <cerrno>
#include <cstring>
#include <unistd.h>
#include "commad.hpp"
#include <cassert>
using namespace std;

int main()
{
    int fd = open(path_name.c_str(), O_WRONLY);
    if(fd == -1)
    {
        cout << errno << ":" << strerror(errno) << endl;
        return 1;
    }

    string str;
    str.resize(100);
    while(true)
    {
        cout << "请输入消息# ";

        getline(cin, str);
        if(str == "quit") break;

        ssize_t n = write(fd, str.c_str(), strlen(str.c_str()));
        assert(n);
        (void)n;
    }
    close(fd);
    return 0;
}